<?php


namespace App\Helpers;


use App\Models\ActionLog;
use App\Models\Java\PdUserRelationship;
use App\Models\Mch\RegisterCode;
use Carbon\Carbon;

trait DivideTrait
{
    // 书籍是否开锁
    protected function getUsersByRoleAndConditions($pid = null, $sid = null, $gid = null)
    {
        // 初始化查询
        $query = PdUserRelationship::where('role', 4);

        // 动态添加条件
        if (!empty($pid)) {
            $query->where('pid', $pid);
        }
        if (!empty($sid)) {
            $query->where('sid', $sid);
        }
        if (!empty($gid)) {
            $query->where('gid', $gid);
        }

        // 返回查询结果
        return $query->get();
    }
}
